﻿using client.utils;
using CommunicationProtocol.dto;
using server.filters;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace client.render
{
    internal class BuyablePlantCreator : ObjectCreator
    {
        public BuyablePlantCreator(Form form, int xLocationOffset, int yLocationOffset) : base(form, xLocationOffset, yLocationOffset)
        {
        }

        protected override void afterRender( PictureBox pictureBox, BaseObject baseObj)
        {
            pictureBox.Click += PictureBox_Click;
            pictureBox.Tag= baseObj;
        }

        private void PictureBox_Click(object senderObj, EventArgs e)
        {
            // 向服务器发起请求，判断植物是否已冷却
            Control sender = (Control)senderObj;

            new InvocationChain(OutBandHolder.OutBand).invoke(
                    new CheckBuyablePlantAvailable(sender.Name)
                ) ;
        }
    }
}
